#ifndef PHOTOMANAGER_H
#define PHOTOMANAGER_H

#include <QObject>
#include <QMap>
#include <QCache>
#include <QPixmap>
#include <QNetworkAccessManager>

namespace ImageDownload {
class PhotoManager : public QObject
{
    Q_OBJECT
public:
    static PhotoManager* instance(QObject *parent = 0);

    void imageGet( const QString& imageUrl );
    bool contains( const QString &imageUrl ) const;
    QPixmap* imageFromUrl( const QString &imageUrl ) const;

protected:
    PhotoManager( QObject *parent = 0 );
    ~PhotoManager();

signals:
    void imageReadyForUrl( const QString& path, QPixmap *image);

Q_SIGNALS:
    // The change notification signals of the properties
    void imageChanged();
    void labelChanged();
    void loadingChanged();

private slots:
    void requestFinished( QNetworkReply *reply );

private:
    QMap<QString,QNetworkAccessManager*> m_connections;
    QCache<QString,QPixmap> m_imageCache;
    static PhotoManager *m_instance;
    QString m_url;
    
};
}

#endif // PHOTOMANAGER_H
